package com.chen.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.chen.pojo.Role;
import com.chen.pojo.UserRole;
import org.apache.ibatis.annotations.*;

import java.util.List;

@SuppressWarnings("all")
@Mapper
public interface RoleMapper extends BaseMapper<Role> {

    //查询所有的角色信息
    @Select("select *from user_role where user_id=#{userId}")
    List<UserRole> getByUserRoleUserId(int userId);

//查询出所有角色
    @Select("select *from role where id=#{userId}")
    List<UserRole> getByUserId(int roleId);

//先删除
    @Delete("delete from user_role where user_id = #{userId}")
    void deleteRoleByUserId(Integer userId);

//    后插入
    @Insert("insert into user_role(user_id, role_id) value(#{userId}, #{roleId})")
    void insertUserRole(@Param("userId") Integer userId, @Param("roleId") Integer roleId);
}
